﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Singleton
{
    /// <summary>
    /// 可对构造函数加参数
    /// </summary>
    class SingletonTwo
    {
        private static volatile SingletonTwo _s;
        private static object lockHelper = new object();
        private SingletonTwo() { }

        public static SingletonTwo GetInstance()
        {
            if (_s == null)
            {
                lock (lockHelper)
                {
                    if (_s == null)
                    {
                        _s = new SingletonTwo();
                    }
                }
            }
            return _s;
        }
    }
}
